﻿@{
    ViewBag.Title = "便利店首页";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@Styles.Render("~/Content/css/business")
<header id="homeTitle" class="Index"></header>
<section id="mainWindows" class="IndexCon"></section>
<section id="shopping" class="Shopping"></section>
<section class="OrderGray" onclick="hideShoppingCar()"></section>
<script>
    window.onload = function () {
        $("body").attr("style", "background: #ffffff;");
        loadTitle();
        TerminalMgr.getMainMenuList(showTerminal, showNoTerminal);
    }

    function showTerminal(menuList) {
        adjustView(menuList);
    }

    function showNoTerminal() {
        $("#shopping").hide();
        window.location.href = '@Url.Content("~/")' + 'Home/IndexNone';
    }

    function adjustView(menuList) {
        loadShopping();
        loadConvenient(menuList);
    }

    function goLocation() {
        window.location.href = '@Url.Content("~/")' + 'Location/Index';
    }

    function goUserCenter() {
        window.location.href = '@Url.Content("~/")' + 'User/Index';
    }

    function loadTitle() {
        var addressName = AddressMgr.getCurName();
        var $div = $(
            '<div class=\"IndexHead\">'
            + '<a class=\"IndexHeadFl fll\" onclick=\"goLocation()\">'
            + '<span>' + addressName + '</span><img src=\"/images/triangle.png">'
            + '</a>'
            + '<a onclick=\"goUserCenter()\" class=\"IndexHeadFr flr\"><img src=\"/images/user.png\"></a>'
            + '</div>');
        $("header#homeTitle").append($div);
    }

    function loadShopping() {
        var shoppingList = ShoppingMgr.getShoppingList();
        var url = '@Url.Content("~/")' + 'Home/Shopping';
        NativeAjax(shoppingList, url, function (msg) {
            loadPartialViewResult(msg, $("#shopping"), 1);
        });
    }

    function loadConvenient(menuList) {
        var mainTab = TerminalMgr.getCurMainTab();
        var subTab = TerminalMgr.getCurSubTab();
        var url = '@Url.Content("~/")' + 'Home/GetMainMenuList' + '?' + 'mainTab=' + mainTab + '&subTab=' + subTab;
        NativeAjax(menuList, url, function (msg) {
            loadPartialViewResult(msg, $("#mainWindows"), 1);
        });
    }

</script>